<template>
    <div>
        <table>
            <tr>
                <td>id</td>
                <td>姓名</td>
                <td>价格</td>
                <td>操作</td>
            </tr>
            <tr v-for="i in list">
                <td>{{i.id}}</td>
                <td>{{i.name}}</td>
                <td>{{i.price}}</td>
                <td><button @click="del(i.id)">删除</button></td>
            </tr>
        </table>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                list:[]
            }
        },
        methods:{
            get_list(){
                 this.$axios.get('http://localhost:5000/a/add/').then(res=>{
                     if(res.data.code==200){
                        this.list = res.data.list
                     }
                     
                 })   
            },
            del(id){
                this.$axios.delete('http://localhost:5000/a/delete/?id='+id)
                .then(res=>{
                    if(res.data.code==200){
                        alert('删除成功')
                    }
                })
            }   
     },
          mounted() {
                this.get_list()
  }
    }
</script>

<style scoped>

</style>